package provider.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import provider.model.OrderModel;
import provider.service.OrderService;

import java.util.Map;

/**
 * Created by 峥桂 on 2017/9/13.
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/sc/order/{id}")
    public OrderModel findOrderById(@PathVariable Long id) {
        OrderModel orderModel = orderService.findOrderByOrderId(id);
        return orderModel;
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello(@RequestParam("name") String name, @RequestParam("age") int age) {
        return name + age;
    }

    @PostMapping("/test/post")
    public OrderModel testPost(@RequestBody OrderModel orderModel) {
        orderModel.setOrderNo(2222222L);
        return orderModel;
    }

    @RequestMapping(value = "/test/get", method = RequestMethod.GET)
    public String testGet(@RequestParam Map<String, Object> map) {
        return String.valueOf(map);
    }

}